# Maintainer: Martell Malone <martellmalone@gmail.com>

_realname=libconfig
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.7.2
pkgrel=1
pkgdesc="C/C++ Configuration File Library (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64')
url="https://github.com/hyperrealm/libconfig"
license=('LGPL')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('!libtool' '!emptydirs')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/hyperrealm/libconfig/archive/v${pkgver}.tar.gz")
sha256sums=('f67ac44099916ae260a6c9e290a90809e7d782d96cdd462cac656ebc5b685726')

prepare() {
  cd "${srcdir}/${_realname}-${pkgver}"
  autoreconf -fiv
}

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  [[ -d "${srcdir}"/build-${MINGW_CHOST} ]] && rm -rf "${srcdir}"/build-${MINGW_CHOST}
  mkdir -p "${srcdir}"/build-${MINGW_CHOST} && cd "${srcdir}"/build-${MINGW_CHOST}
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --enable-shared \
    --enable-static

  make lib
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}/lib"
  make DESTDIR="${pkgdir}" install
}
